/* $RCSFile: MasterListItem.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/ADNCRM.Core/Design/MasterListItem.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:28  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Collections;
using System.Configuration;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.IO;
using AddonNice.Helpers;

using Path2     =   AddonNice.Settings.Path;

namespace AddonNice.Design
{	
	/// <summary>
    /// NameListItem encapsulates the items of any name/value usefull to display items in a CustomListDataType
	/// Uses IComparable interface to allow sorting by name.
	/// </summary>
	public class MasterListItem : IComparable 
	{
        private string _name                            =   string.Empty;
		private ItemOrigin _origin                      =   ItemOrigin.Public;

        string  _WebPath                                =   string.Empty;

		/// <summary>
		/// The name of the layout
		/// </summary>
		public string Name 
		{
			get 
			{
				return _name;
			}
		}


		public ItemOrigin Origin
		{
			get 
			{
				return _origin;
			}
			set 
			{
				_origin = value;
			}
		}

        public string WebPath
		{
			get 
			{
				return _WebPath;
            }
        }
        
        public MasterListItem(string nm,string gwebpath,ItemOrigin org)
        {
            _name               =   nm;
            _origin             =   org;
            // _WebPath contains the full path to load the master page
            if (!string.IsNullOrEmpty(nm) && !string.IsNullOrEmpty(gwebpath))
            {
                string wwebpath = Path2.RemoveTrailingSlash(gwebpath);
                _WebPath = string.Format("{0}/{1}.master", wwebpath, nm);
            }
        }

 
		public int CompareTo(object value) 
		{
            if ( value is MasterListItem )
			    return WebPath.CompareTo(((MasterListItem)value).WebPath);
            return -1;
		}
	}
}